#!/bin/bash -x
USERNAME=spruce
PASSWORD=spruce
DVN_SERVER=localhost:8181
if [ -z "$1" ]; then
  EDIT_MEDIA_URL=`scripts/api/data-deposit/list-datasets | xpath 'string(//link/@href)' 2>/dev/null`
else
  EDIT_MEDIA_URL=$1
fi
curl -s --insecure --data-binary @scripts/search/data/binary/trees.zip -H "Content-Disposition: filename=trees.zip" -H "Content-Type: application/zip" -H "Packaging: http://purl.org/net/sword/package/SimpleZip" -u $USERNAME:$PASSWORD $EDIT_MEDIA_URL \
| xmllint -format -
#curl -s --insecure --data-binary @scripts/search/data/binary/trees.zip -H "Content-Disposition: filename=trees.zip" -H "Content-Type: application/zip" -H "Packaging: http://purl.org/net/sword/package/SimpleZip" https://$USERNAME:$PASSWORD@$DVN_SERVER/dvn/api/data-deposit/v1/swordv2/edit-media/study/doi:10.5072/FK2/19 \
#| xmllint -format -
